package com.voicechat.firstmet.net.service;

import android.text.TextUtils;
import android.util.Log;

import com.voicechat.firstmet.bean.FristMetBean;
import com.voicechat.firstmet.bean.Result;
import com.voicechat.firstmet.bean.ShareGirlsBean;
import com.voicechat.firstmet.bean.ShareGirlsDetailsBean;
import com.voicechat.firstmet.bean.ShareGirlsOrderBean;
import com.voicechat.firstmet.bean.SharePhotoBean;
import com.voicechat.firstmet.net.Params;

import rx.Observable;

/**
 * @ProjectName: FirstMet
 * @Package: com.voicechat.firstmet.net.service
 * @ClassName: MeInfoService
 * @Description: 隐约service
 * @Author: ljp
 * @CreateDate: 2018/10/22 15:50
 * @Version: 1.0
 */
public class FaintService extends BaseService {
    private static String TAG = "FaintService";

    /**
     * @return
     * @method
     * @description 上传共享照片
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> uploadingSharePicture(String userId, String token,
                                                           String equipmentId,String albumUrl, String coverUrl,
                                                           String title,String gold
    ) {
        Params params = new Params();
        params.put("userId", userId);//用户id
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("imgUrl", albumUrl);//照片地址
        params.put("coverUrl",coverUrl);
        params.put("gold",Integer.valueOf(gold));
        params.put("title", title);//照片地址
        Log.i("FaintService", "uploadingSharePicture" + params.toString());
        return sNetInterface.uploadingSharePicture(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 查询共享照片
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<SharePhotoBean> selectSharePicture(String nowUserId, String token,
                                                                String equipmentId, int pageNo,int flag

    ) {
        Params params = new Params();
        params.put("nowUserId", nowUserId);//当前使用者用户id
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("flag", flag);//标记 0最新 1人气
        params.put("pageNo", pageNo);
        params.put("pageSize", 10);//一页返回多少条数据 默认10
        Log.i("FaintService", "selectSharePicture" + params.toString());
        return sNetInterface.selectSharePicture(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 查询自己的共享照片
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<SharePhotoBean> selectSharePictureMy(String userId, String token,
                                                                String equipmentId, int pageNo

    ) {
        Params params = new Params();
        params.put("nowUserId", userId);//当前使用者用户id
        params.put("userId", userId);//用户id
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("pageNo", pageNo);
        params.put("pageSize", 10);//一页返回多少条数据 默认10
        Log.i("FaintService", "selectSharePicture" + params.toString());
        return sNetInterface.selectSharePicture(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 更新支付标记
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> signPaySharePicture(String userId, String token,
                                                                String equipmentId,String id
    ) {
        Params params = new Params();
        params.put("userId", userId);//用户id
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("id", id);//相册id
        params.put("sign", 1);
        Log.i("FaintService", "selectSharePicture" + params.toString());
        return sNetInterface.signPaySharePicture(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 照片支付金币
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> paySharePicture(String userId, String token,
                                                     String equipmentId,String albumId,int gold
    ) {
        Params params = new Params();
        params.put("userId", userId);//用户id
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("albumId", albumId);//相册id
        params.put("gold", gold);
        Log.i("FaintService", "selectSharePicture" + params.toString());
        return sNetInterface.paySharePicture(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 更新浏览量
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<SharePhotoBean> pageViewSharePicture(String userId, String token,
                                                     String equipmentId,String id
    ) {
        Params params = new Params();
        params.put("userId", userId);//用户id
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("id", id);//相册id
        Log.i("FaintService", "selectSharePicture" + params.toString());
        return sNetInterface.pageViewSharePicture(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 发布共享闺蜜
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result> shareGirlsPublish(Params params) {
      /*  Params params = new Params();
        params.put("userId", userId);//用户id
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("falg", falg);//标记 0最新 1人气
        params.put("pageNo", pageNo);
        params.put("pageSize", 10);//一页返回多少条数据 默认10*/
        Log.i("FaintService", "selectSharePicture" + params.toString());
        return sNetInterface.shareGirlsPublish(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 共享闺蜜列表查询
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<ShareGirlsBean> shareGirlsSelect(String token, String equipmentId,String address,
                                                              int pageNo,String province) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("address", address);//相册id
        params.put("province", province);//相册id
        params.put("pageNo", pageNo);
        params.put("pageSize", 10);//一页返回多少条数据 默认10
        Log.i("FaintService", "selectSharePicture" + params.toString());
        return sNetInterface.shareGirlsSelect(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description  共享秀照删除
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result>  deleteSharePhoto(String token, String equipmentId,String albumId
    ) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("id", albumId);//图片id
        //Log.i("LoginService", "setMsgRead" + params.toString());
        return sNetInterface.deleteSharePhoto(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description  共享闺蜜详情
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<ShareGirlsDetailsBean>  shareGirlsDetails(String token, String equipmentId, String albumId
    ) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("id", albumId);//图片id
        //Log.i("LoginService", "setMsgRead" + params.toString());
        return sNetInterface.shareGirlsDetails(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description  查看附件的人
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<FristMetBean>  attachmentPerson(String token, String equipmentId,
                                                                      String userId,String longitude,String dimension,int pageNo
    ) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("id", userId);
        if(!TextUtils.isEmpty(longitude)){
            params.put("longitude",Double.parseDouble(longitude));
            params.put("dimension", Double.parseDouble(dimension));
        }
        params.put("pageNo", pageNo);
        params.put("pageSize", 20);//一页返回多少条数据 默认10
        Log.i("LoginService", "setMsgRead" + params.toString());
        return sNetInterface.attachmentPerson(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description 我的共享闺蜜列表查询
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<ShareGirlsBean> shareMyGirlsSelect(String token, String equipmentId,
                                                              int pageNo,String id,String selectType) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        if(!TextUtils.isEmpty(selectType)){
            params.put("selectType",1);
        }
        params.put("userId", id);//用户id
        params.put("pageNo", pageNo);
        params.put("pageSize", 10);//一页返回多少条数据 默认10
        Log.i("FaintService", "selectSharePicture" + params.toString());
        return sNetInterface.shareMyGirlsSelect(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description  共享闺蜜删除
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result>  deleteShareGirls(String token, String equipmentId,String albumId
    ) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("id", albumId);//图片id
        //Log.i("LoginService", "setMsgRead" + params.toString());
        return sNetInterface.deleteShareGirls(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description  共享闺蜜预订单
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<ShareGirlsDetailsBean>  shareGirlsOrder(String token, String equipmentId,String friendReleaseId,String userId,
                                                      String address, int time,int accompany,String remarks
    ) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("friendReleaseId", friendReleaseId);//闺蜜信息id
        params.put("userId", userId);//自己的id
        params.put("address", address);//约会地点
        params.put("time",time);//约会时间
        params.put("accompany", accompany);//陪同标记
        if (!TextUtils.isEmpty(remarks)) {
            params.put("remarks", remarks);//备注
        }
        params.put("address", address);//约会地点
        params.put("receiptStatus",0);//接单状态 初始值0 1拒绝 2同意
        params.put("complete", 2);//完成状态 1完成 2未完成 3取消 4已退款 5拒绝退款  初始值2
        params.put("cancelSign", 2);//取消约会标记 初始值2 1可取消 2不可取消
        return sNetInterface.shareGirlsOrder(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description  好友申请标记已读
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result>  friendsRead(String token, String equipmentId,String userId
    ) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("userId", userId);//自己的id
        //Log.i("LoginService", "setMsgRead" + params.toString());
        return sNetInterface.friendsRead(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description  查询共享闺蜜下单列表
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<ShareGirlsOrderBean>  selectShareGirlsPlaceOrder(String token, String equipmentId, String userId
    ) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("userId", userId);//自己的id
        //Log.i("LoginService", "setMsgRead" + params.toString());
        return sNetInterface.selectShareGirlsPlaceOrder(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description  查询共享闺蜜接收到订单列表
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<ShareGirlsOrderBean>  selectShareGirlsReceiveOrder(String token, String equipmentId,String userId
    ) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("userId", userId);//自己的id
        //Log.i("LoginService", "setMsgRead" + params.toString());
        return sNetInterface.selectShareGirlsReceiveOrder(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description  取消/完成/6申请退款订单
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result>  completeCancelOrder(String token, String equipmentId,String id,int complete,int rmb
    ) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("id", id);//订单id
        params.put("complete",complete);//完成状态 1完成 2未完成 3取消 4已退款 5拒绝退款 6申请退款
        params.put("rmb", rmb);//实际支付金额
        Log.i("LoginService", "setMsgRead" + params.toString());
        return sNetInterface.completeCancelOrder(params).compose(applySchedulers());
    }
    /**
     * @return
     * @method
     * @description  接受/拒绝订单（接受订单是receiptStatus传2）
     * @date: 2018/9/17 19:24
     * @author: ljp
     */
    public static Observable<Result>  acceptRejectionOrder(String token, String equipmentId,String id,int rmb,int receiptStatus
    ) {
        Params params = new Params();
        params.put("token", token);
        params.put("equipmentId",equipmentId);
        params.put("id", id);//订单id
        params.put("receiptStatus",receiptStatus);//接单状态 0初始值 1拒绝 2同意
        if(receiptStatus == 1){
            params.put("complete",6);//完成状态 6申请退款   //只有receiptStatus 为1才传
        }
        params.put("rmb", rmb);//实际支付金额
        Log.i("LoginService", "setMsgRead" + params.toString());
        return sNetInterface.acceptRejectionOrder(params).compose(applySchedulers());
    }
}
